package com.example.crossmall.service.impl;

import com.example.crossmall.mapper.ClassificationMapper;
import com.example.crossmall.po.Classification;
import com.example.crossmall.po.ClassificationExample;
import com.example.crossmall.service.ClassificationService;
import com.example.crossmall.util.PageUtil;
import org.hibernate.criterion.Example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassificationServiceImpl implements ClassificationService {
    @Autowired
    private ClassificationMapper classificationMapper;


    @Override
    public Classification findById(int id) {
        return classificationMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Classification> findAll(int type) {
        return null;
    }

    @Override
    public void update(Classification Classification) {
        classificationMapper.updateByPrimaryKeySelective(Classification);
    }

    @Override
    public int create(Classification Classification) {
        return 0;
    }

    @Override
    public void delById(int id) {

    }

    @Override
    public List<Classification> findByParentId(int cid) {
        return null;
    }

    @Override
    public Page<Classification> findAll(int type, Pageable pageable) {
        ClassificationExample example = new ClassificationExample();
        ClassificationExample.Criteria criteria = example.createCriteria();
        criteria.andTypeEqualTo(type);
        List<Classification> classList = classificationMapper.selectByExample(example);
        return new PageUtil().listConvertToPage(classList, pageable);
    }

    @Override
    public List<Classification> findAllExample(ClassificationExample example) {
        return null;
    }
}
